<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>
        员工信息
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="../../../../css/main.css" media="all">
    <script type="text/javascript" src="../../../../lib/loading/okLoading.js"></script>
    <link rel="stylesheet" href="../../../../lib/layui/css/layui_2.5.7.css">

</head>
<style>

</style>

<body>
<div class="x-nav">
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon"
                                                                        style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body" id="app">
    <form class="layui-form layui-form-pane" id="add">
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">

                <div class="layui-inline layui-form-item">
                    <label class="layui-form-label"> <span class='x-red'>*</span>姓名</label>
                    <div class="layui-input-inline">
                        <input  autocomplete="off"  type="text" name="nickname" v-model="user.nickname"
                               lay-verify="required" placeholder="姓名" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline layui-form-item">
                    <label style="width: 120px" class="layui-form-label"> <span class='x-red'></span>手机</label>
                    <div class="layui-input-inline">
                        <input  autocomplete="off"  type="text" name="phone"
                               v-model="user.phone" placeholder="手机" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline layui-form-item">
                    <label class="layui-form-label"> <span class='x-red'>*</span>性别</label>
                    <div class="layui-input-inline">
                        <select lay-verify="required" name="gender" lay-search="">
                            <option value="">---</option>
                            <option value="男">男</option>
                            <option value="女">女</option>
                        </select>

                    </div>
                </div>
                <div class="layui-inline layui-form-item">
                    <label style="width: 120px" class="layui-form-label"> <span class='x-red'></span>部门</label>
                    <div class="layui-input-inline">
                        <select name="department" lay-search="">
                            <option value="">---</option>
                        </select>
                    </div>
                </div>
                <!--<div class="layui-inline layui-form-item">-->
                    <!--<label class="layui-form-label"> <span class='x-red'></span>职位</label>-->
                    <!--<div class="layui-input-inline ">-->
                        <!--<select name="position" lay-search="">-->
                            <!--<option value="">-&#45;&#45;</option>-->
                        <!--</select>-->
                    <!--</div>-->
                <!--</div>-->
                <div class=" layui-form-item layui-inline">
                    <label class="layui-form-label"> <span class='x-red'></span>PC端权限</label>
                    <div class="layui-input-inline ">
                        <select name="roleId" lay-search="">
                            <option value="0">---</option>
                        </select>
                    </div>
                </div>
                <div class=" layui-form-item layui-inline">
                    <label style="width: 120px" class="layui-form-label"> <span class='x-red'></span>公众号端权限</label>
                    <div class="layui-input-inline ">
                        <select name="roleWxmpId" lay-search="">
                            <option value="0">---</option>
                        </select>
                    </div>
                </div>


                <div class="layui-inline layui-form-item">
                    <label class="layui-form-label">
                        <span class='x-red'></span>联系方式
                    </label>
                    <div class="layui-input-inline">
                        <input  autocomplete="off"  name="otherContact" v-model="user.otherContact" autocomplete="off"
                               placeholder="联系方式" class="layui-input">
                    </div>
                </div>

                <div class="layui-inline layui-form-item">
                    <label style="width: 120px" class="layui-form-label">
                        <span class='x-red'></span>微信绑定
                    </label>
                    <div class="layui-input-inline">
                        <input  autocomplete="off"  type="text" name="wxOpenid" v-model="user.wxOpenid" autocomplete="off"
                               placeholder="微信绑定" class="layui-input">
                    </div>
                </div>


                <div class="layui-inline layui-form-item">
                    <label class="layui-form-label">
                        <span class='x-red'>*</span>账号
                    </label>
                    <div class="layui-input-inline">
                        <input  autocomplete="off"  type="text" name="username" v-model="user.username" autocomplete="off"
                               placeholder="账号" class="layui-input" lay-verify="required">
                    </div>
                </div>

                <div class="layui-inline layui-form-item">
                    <label style="width: 120px" class="layui-form-label"> <span class='x-red'></span>密码</label>
                    <div class="layui-input-inline">
                        <input  autocomplete="off"  type="password" name="pwd" v-model="user.pwd"
                               placeholder="密码" class="layui-input">
                    </div>
                </div>
                <div class=" layui-form-item">
                    <label class="layui-form-label">
                        <span class='x-red'></span>入职时间
                    </label>
                    <div class="layui-input-block">
                        <input  autocomplete="off"  type="text" name="joinTime" v-model="user.joinTime" id="joinTime"
                               placeholder="入职时间" class="layui-input" readonly>
                    </div>
                </div>
                <div class="layui-inline layui-form-item">
                    <label class="layui-form-label">
                        <span class='x-red'></span>合同到期
                    </label>
                    <div class="layui-input-inline">
                        <input  autocomplete="off"  type="text" name="contractEndTime" v-model="user.contractEndTime" id="contractEndTime"
                               autocomplete="off" readonly
                               placeholder="合同到期" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline layui-form-item">
                    <label class="layui-form-label">
                        <span class='x-red'></span>保险到期
                    </label>
                    <div class="layui-input-inline">
                        <input  autocomplete="off"  type="text" name="insuranceEndTime" v-model="user.insuranceEndTime" id="insuranceEndTime"
                               autocomplete="off" readonly
                               placeholder="保险到期" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline layui-form-item">
                    <label class="layui-form-label">
                        <span class='x-red'></span>操作证号
                    </label>
                    <div class="layui-input-inline">
                        <input  autocomplete="off"  type="text" name="operationCertificateNo" v-model="user.operationCertificateNo"
                               autocomplete="off"
                               placeholder="操作证号" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline layui-form-item">
                    <label class="layui-form-label">
                        <span class='x-red'></span>有效期至
                    </label>
                    <div class="layui-input-inline">
                        <input  autocomplete="off"  type="text" name="operationCertificateNoEndTime" id="operationCertificateNoEndTime"
                               v-model="user.operationCertificateNoEndTime"
                               autocomplete="off" readonly
                               placeholder="有效期至" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline layui-form-item">
                    <label class="layui-form-label">
                        <span class='x-red'></span>A4
                    </label>
                    <div class="layui-input-inline">
                        <input  autocomplete="off"  type="text" name="a4" v-model="user.a4"
                               autocomplete="off"
                               placeholder="A4" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline layui-form-item">
                    <label class="layui-form-label">
                        <span class='x-red'></span>有效期至
                    </label>
                    <div class="layui-input-inline">
                        <input  autocomplete="off"  type="text" name="a4EndTime" v-model="user.a4EndTime" id="a4EndTime"
                               autocomplete="off" readonly
                               placeholder="有效期至" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline layui-form-item">
                    <label class="layui-form-label">
                        <span class='x-red'></span>质检证号
                    </label>
                    <div class="layui-input-inline">
                        <input  autocomplete="off"  type="text" name="qualityInspectionCertificateNo"
                               v-model="user.qualityInspectionCertificateNo"
                               autocomplete="off"
                               placeholder="质检证号" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline layui-form-item">
                    <label class="layui-form-label">
                        <span class='x-red'></span>有效期至
                    </label>
                    <div class="layui-input-inline">
                        <input  autocomplete="off"  type="text" name="qualityInspectionCertificateNoEndTime"
                               id="qualityInspectionCertificateNoEndTime"
                               v-model="user.qualityInspectionCertificateNoEndTime"
                               autocomplete="off" readonly
                               placeholder="有效期至" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline layui-form-item">
                    <label class="layui-form-label">
                        <span class='x-red'></span>身份证
                    </label>
                    <div class="layui-input-inline">
                        <input  autocomplete="off"  type="text" name="idcard" v-model="user.idcard"
                               autocomplete="off"
                               placeholder="身份证" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline layui-form-item">
                    <label class="layui-form-label">
                        <span class='x-red'></span>有效期至
                    </label>
                    <div class="layui-input-inline">
                        <input  autocomplete="off"  type="text" name="idcardEndTime" v-model="user.idcardEndTime" id="idcardEndTime"
                               autocomplete="off" readonly
                               placeholder="有效期至" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label"> <span class='x-red'></span>备注信息</label>
                    <div style="width: 70%" class="layui-input-inline">
                        <textarea name="remarks" placeholder="请输入内容" v-model="user.remarks"
                                  class="layui-textarea"></textarea>
                    </div>
                </div>
                <br>

                <div style="text-align: center" class="layui-form-item">
                    <button class="layui-btn" type="button" lay-filter="sub" lay-submit="sub">
                        保存
                    </button>
                </div>
                <!--</form>-->
                <div style="height:100px;"></div>
            </div>


        </div>

    </form>
</div>
<script type="text/javascript" src="../../../../js/jquery.min.js"></script>
<script type="text/javascript" src="../../../../js/myAjax.js"></script>
<script type="text/javascript" src="../../../../js/pub.js"></script>
<script src="../../../../lib/layui/layui2.5.7.js" charset="utf-8"></script>
<script src="../../../../js/x-layui.js" charset="utf-8"></script>
<script src="../../../../js/vue.min.js" charset="utf-8"></script>

<script>
    layui.use(['element', 'layer', 'form', 'laydate'], function () {
        $ = layui.jquery;//jquery
        lement = layui.element();//面包导航
        layer = layui.layer;//弹出层
        laydate = layui.laydate;//日期插件
        form = layui.form;
        okLoading.close($);
    })

</script>
<script>

    var recordId = getQueryVariable("recordId");

    layui.use(['laydate', 'form', 'layer'],
        function () {
            var laydate = layui.laydate;
            var $ = layui.jquery;
            var form = layui.form;
            var layer = layui.layer;

            laydate.render({
                elem: '#joinTime',
                trigger: 'click',
                type: 'date',
                done: function (value, date, endDate) {
                    vm.user.joinTime = value
                }
            });
            laydate.render({
                elem: '#contractEndTime',
                trigger: 'click',
                type: 'date',
                done: function (value, date, endDate) {
                    vm.user.contractEndTime = value
                }
            });
            laydate.render({
                elem: '#insuranceEndTime',
                trigger: 'click',
                type: 'date',
                done: function (value, date, endDate) {
                    vm.user.insuranceEndTime = value
                }
            });
            laydate.render({
                elem: '#idcardEndTime',
                trigger: 'click',
                type: 'date',
                done: function (value, date, endDate) {
                    vm.user.idcardEndTime = value
                }
            });
            laydate.render({
                elem: '#qualityInspectionCertificateNoEndTime',
                trigger: 'click',
                type: 'date',
                done: function (value, date, endDate) {
                    vm.user.qualityInspectionCertificateNoEndTime = value
                }
            });
            laydate.render({
                elem: '#a4EndTime',
                trigger: 'click',
                type: 'date',
                done: function (value, date, endDate) {
                    vm.user.a4EndTime = value
                }
            });
            laydate.render({
                elem: '#operationCertificateNoEndTime',
                trigger: 'click',
                type: 'date',
                done: function (value, date, endDate) {
                    vm.user.operationCertificateNoEndTime = value
                }
            });

            //监听审批提交
            form.on('submit(sub)',
                function (data) {
                    let form = data.field;
                    form.userId = $userId;
                    form.id = vm.user.id;
                    vm.user.id == null ? form.operationType = 'add' : form.operationType = 'edit';

                    let request = {
                        url: 'user/addUser',
                        data: form,
                        method: "post",
                    };
                    sendRequest(request, (data) => {
                        if (data.code === 0) {
                            layer.alert("操作成功", {
                                    icon: 6
                                },
                                function () {
                                    var index = parent.layer.getFrameIndex(window.name);
                                    parent.layer.close(index);
                                    parent.reload();


                                });
                        } else {
                            layer.alert(data.msg, {
                                icon: 5
                            })
                        }
                    });
                    return false;
                });


        });

    const vm = new Vue({
        el: "#app",
        data: {
            user: {
                id: null,
                nickname: null,
                phone: null,
                gender: null,
                department: null,
                position: null,
                otherContact: null,
                wxOpenid: null,
                wxNickname: null,
                wxHeadimgurl: null,
                username: null,
                pwd: null,
                joinTime: null,
                contractEndTime: null,
                insuranceEndTime: null,
                operationCertificateNo: null,
                operationCertificateNoEndTime: null,
                a4: null,
                a4EndTime: null,
                qualityInspectionCertificateNo: null,
                qualityInspectionCertificateNoEndTime: null,
                idcard: null,
                idcardEndTime: null,
                remarks: null,
                status: null,
                roleId: null,
                roleWxmpId: null,
            }
        },
        created() {

            if (recordId) {
                let request = {
                    url: 'user/findUser',
                    data: {
                        userId: $userId,
                        recordId: recordId
                    },
                    method: "POST"
                }
                sendRequest(request, (res) => {
                    let d = res.data;
                    d.pwd = null;
                    this.user = d;
                })
            }

        }

    });

    setTimeout(() => {
        //修改状态
        let form = layui.form;
        $("select[name=gender]").val(vm.user.gender);
        //查部门列表select
        let request = {
            url: 'organizationStructure/getOrganizationStructureSelect',
            data: {
                userId: $userId,
            },
            method: "POST",
        };
        sendRequest(request, (res) => {
            // console.log(res);
            let billType = res.data;
            $.each(billType, function (index, item) {
                let opt = $("<option value=" + item.id + ">" + item.information + "</option>");
                $("select[name=department]").append(opt);
            });
            $("select[name=department]").val(vm.user.department);
            form.render('select');
        });
        form.render('select');


        let request1 = {
            url: 'admin/findRoleList',
            data: {
                userId: $userId,
            },
            method: "get",
        };
        sendRequest(request1, (res) => {
            let d = res.data;
            $.each(d, function (index, item) {
                let opt = $("<option value=" + item.id + ">" + item.roleName + "</option>");
                $("select[name=roleId]").append(opt);
            });

            $("select[name=roleId]").val(vm.user.roleId);
            form.render('select');

        });
        form.render('select');

        let request2 = {
            url: 'admin/findRoleWxmpList',
            data: {
                userId: $userId,
            },
            method: "get",
        };
        sendRequest(request2, (res) => {
            let d = res.data;
            $.each(d, function (index, item) {
                let opt = $("<option value=" + item.id + ">" + item.roleName + "</option>");
                $("select[name=roleWxmpId]").append(opt);
            });

            $("select[name=roleWxmpId]").val(vm.user.roleWxmpId);
            form.render('select');

        });
        form.render('select');
        //职位
        // let request2 = {
        //     url: 'dictionary/findDataDictionaryValue',
        //     data: {
        //         userId: $userId,
        //         label: 'ZHI_WEI'
        //     },
        //     method: "POST",
        // };
        // sendRequest(request2, (res) => {
        //     let x = res.data;
        //     $.each(x, function (index, item) {
        //         let opt = $("<option value=" + item + ">" + item + "</option>");
        //         $("select[name=position]").append(opt);
        //     });
        //     $("select[name=position]").val(vm.user.position);
        //     form.render('select');
        // });

    }, 500)

</script>

</body>

</html>
